<?xml version="1.0" encoding="utf-8"?>
<Content xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="urn:blueonionsoftware-com:bloget:runtime:data">
  <text>&lt;strong&gt;The problem&lt;/strong&gt;
Many times we want to observe a dynamic view some variable's contents during runtime - the behavior and flow of changing data is ofter useful and critical information to understand a problem.  You could set a breakpoint, but many times you can't get the debugger to hit the break point under just the right circumstances, or the very circumstance of hitting the breakpoint and activating the debugger changes the runtime behavior in such a way that you can't reach the code you're interested in.  

In these cases, a common technique used to monitor values during a process run is to pepper your code with System.Console.Writeline statements, or to insert Prober log statements.  Many times you need to stop the process, modify code, and rebuild to get that log statement you forgot to put in particular method, dumping a particular variable that you forgot to include, etc.  And later, these statements will have to be manually removed once you've obtained the gnosis you seek - with another rebuild and diagnostic run required to verify you don't have to buy donuts the next day.

&lt;strong&gt;The Insight&lt;/strong&gt;
I came across a new way to get this same information at runtime, without changing code at all, requiring no rebuilds, and 99% of the time giving me just what I need. 

It turns out you can set breakpoints that don't ever stop execution, but instead just print whatever you want to the console, including stack traces, just the preceeding method, variable contents, etc.  There is a rich set of simple macros and syntax to create a wide variety of console statements with useful information.

&lt;strong&gt;Step by step:&lt;/strong&gt;
To stage for this, you just need your process built in debug mode, and run it through the debugger to use the following technique.

&lt;ol&gt;
	&lt;li&gt;Go to an area in the code where some interesting reside.&lt;/li&gt;
	&lt;li&gt;Set a breakpoint following a code line where values are set / modified. (See Step 2 image below)&lt;/li&gt;
	&lt;li&gt;Right click on the breakpoint, select "Breakpoint&gt;" from the context menu, and then choose "When Hitâ€¦" (See Step 3 image below)&lt;/li&gt;
	&lt;li&gt;In the dialog box that appears, check "Print a message" and then you probably also want "Continue Execution" checked as well (but you can toggle this when you want)&lt;/li&gt;
	&lt;li&gt;In the message text box, any text you type will appear in the console output, any variables within curly braces will be evaluated and their ToString results will be inserted into the console output.  And execution will continue.  Other macros, documented in the dialog box, can be inserted as well.&lt;/li&gt;
	&lt;li&gt;And you don't have to find all the places to clean out your logging statements later - just delete all your breakpoints.&lt;/li&gt;
&lt;/ol&gt;


&lt;strong&gt;Step 2:&lt;/strong&gt;
&lt;img src="http://aabmag23a/devnotes/wp-content/breakpoint_tip1.png" alt="Step 2" /&gt;


&lt;strong&gt;Step 3:&lt;/strong&gt;
&lt;img src="http://aabmag23a/devnotes/wp-content/breakpoint_tip2.png" alt="Step 3" /&gt;


&lt;strong&gt;Step 4:&lt;/strong&gt;
&lt;img src="http://aabmag23a/devnotes/wp-content/breakpoint_tip3.png" alt="Step 4" /&gt;


</text>
  <last_update>2007-10-04T00:52:31.9110806Z</last_update>
  <source_title />
  <source_link />
  <comments />
  <references />
  <attachments />
</Content>